<!--
 * @Descripttion: 供应商导入导出
 * @version: V1.0
 * @Author: GaoWei
 * @Date: 2021-06-17 15:49:11
 * @LastEditors: GW
 * @LastEditTime: 2021-12-01 15:08:39
-->
<template>
    <div>

        <!-- <a-menu-item key="3" @click="importFile" v-if="permissions.includes('crm:clue:import')">
            <a-icon type="user" />导入
        </a-menu-item>
        <a-menu-item key="5" @click="() => (exportVisible = true)" v-if="permissions.includes('crm:clue:export')">
            <a-icon type="user" />导出
        </a-menu-item> -->
        <!-- modal 弹窗  -->
        <a-modal v-model="exportVisible" title="导出客户数据文件" centered on-ok="handleok" width="650px">
            <div style="margin-left:30px;height: 200px;overflow-y: scroll;">
                <a-radio-group v-model="exportRadioValue">
                    <p>
                        <a-radio value="1">导出所选客户：{{exportValue || 0}}条</a-radio>
                    </p>
                    <p>
                        <a-radio value="2">导出符合条件客户：{{pagination.total || 0}}条</a-radio>
                    </p>
                </a-radio-group>
            </div>
            <template slot="footer">
                <a-button key="submit" type="primary" icon="download" @click="exportCrmData">导出</a-button>
                <a-button key="back" @click="() => (exportVisible = false)" icon="close">取消</a-button>
            </template>
        </a-modal>

        <a-modal v-model="importVisible" title="导入供应商档案" centered on-ok="handleok" width="650px">
            <div style="margin-left:30px;">

                <div style="font-weight: normal;">
                    <div>
                        第1步：
                        下载供应商档案导入模板，<a href="javascript:;" @click="downloadTemplate" style="font-size: 12px;color: blue;">点击下载模板</a>
                    </div>
                    <br>
                    <div>
                        第2步：上传文档
                        <label>
                            <input type="file" id="file" name="file" style="padding-left: 15px;" class="form-file" />
                        </label>
                    </div>
                </div>
                <br>

                <div>
                    <span>第3步:导入资料至</span>
                    <label style="padding-left: 15px;">
                        <input name="Fruit" type="radio" checked />供应商档案
                    </label>
                </div>
                <!-- <div>
                        <span>第3步:导入资料至</span>
                        <label style="padding-left: 15px;">
                            <input name="Fruit" type="radio" checked />线索公海
                        </label>
                    </div> -->
                <div style="margin-top: 15px;">
                    <p>导入说明</p>
                    <div style="margin-left:20px">
                        <p>1.下载导入模板</p>
                        <p>2.上传存储有供应商档案的Excel文件，大小不超过5M</p>
                        <p>3.开始导入</p>
                    </div>
                </div>
                <!-- <div style="margin-top: 25px;">
                        <p>
                            <sapn style="color:red;font-size: 18px;">*</sapn>'所属地区'栏目格式说明
                        </p>
                        <p>1.可以传入省市区的组合(例：a.四川省 b.四川省/成都市 c.四川省/成都市/锦江区 )</p>
                        地区助手：
                        <a-cascader placeholder="请选择地区" change-on-select show-search :field-names="{ label: 'areaName', value: 'areaCode',children: 'children'}" @change="onAreaChange" :options="regions" />
                        '所属地区'：<sapn style="color:red;">{{ areaText }}</sapn>
                    </div> -->
            </div>
            <template slot="footer">
                <a-button key="submit" type="primary" @click="importCrm">下一步</a-button>
                <a-button key="back" @click="() => (importVisible = false)">取消</a-button>
            </template>
            <div class="import-modal-mask" v-if="importEnd">
                <a-spin class="loading-content" tip="导入中..." />
            </div>
        </a-modal>

        <a-modal v-model="filedVisible" title="匹配导入字段" centered on-ok="handleok" width="650px">
            <a-spin :spinning="isSpinning" tip="导入中...">
                <div style="margin-left:30px;height: 400px;overflow-y: scroll;">
                    <a-table :columns="filedColumns" :data-source="filedData" :pagination="false" bordered>
                        <template slot="crmFiled" slot-scope="text, record">
                            <a-select title="下拉效果" size="small" style="width:80%;height:100%" labelStyle="display: none;" v-model="record.crmCode">
                                <a-select-option v-for="(item,index) in record.crmFiled" :key="index" :value="item.key">{{item.title}}</a-select-option>
                            </a-select>
                        </template>
                    </a-table>
                </div>
            </a-spin>

            <template slot="footer">
                <a-button v-show="!isSpinning" key="submit" type="primary" @click="importData">导入</a-button>
                <a-button v-show="!isSpinning" key="back" @click="() => (filedVisible = false)">取消</a-button>
            </template>
        </a-modal>

        <a-modal v-model="resultVisible" title="导入结果" centered on-ok="handleok" width="650px">
            <div style="margin-left:30px;height: 200px;overflow-y: scroll;">
                <p>导入成功数：{{impotrResult.successNum || 0}}</p>
                <p>导入失败数：{{impotrResult.failNum || 0}}</p>
                <p>如果您需要导入失败的记录及原因，请点击下载按钮</p>
            </div>
            <template slot="footer">
                <a-button key="submit" type="primary" icon="download" @click="downloadImportResult">下载</a-button>
                <a-button key="back" @click="() => (resultVisible = false)" icon="close">取消</a-button>
            </template>
        </a-modal>

        <a-modal v-model="exportVisible" title="导出客户数据文件" centered on-ok="handleok" width="650px">
            <div style="margin-left:30px;height: 200px;overflow-y: scroll;">
                <a-radio-group v-model="exportRadioValue">
                    <p>
                        <a-radio value="1">导出所选客户：{{exportValue || 0}}条</a-radio>
                    </p>
                    <p>
                        <a-radio value="2">导出符合条件客户：{{pagination.total || 0}}条</a-radio>
                    </p>
                </a-radio-group>
            </div>
            <template slot="footer">
                <a-button key="submit" type="primary" icon="download" @click="exportCrmData">导出</a-button>
                <a-button key="back" @click="() => (exportVisible = false)" icon="close">取消</a-button>
            </template>
        </a-modal>

        <a-modal v-model="userModal" centered title="分配客户给" width="300px">
            <div style="height: 400px;overflow-y:scroll;">
                <a-input-search style="margin-bottom: 8px" placeholder="输入用户名称" @change="onChange" />
                <div v-show="treeAShow">
                    <a-tree :selected-keys="selectedUserKeys" :tree-data="userSearchData" :expanded-keys="expandedUserKeys" @expand="expanedChange" :defaultExpandAll="true" @select="onUserSelect" :checkable="false" :show-icon="true">
                        <a-icon slot="user" type="user" />
                    </a-tree>
                </div>
                <div v-show="treeBShow">
                    <a-tree :selected-keys="selectedUserKeys" :tree-data="userAllData" :defaultExpandAll="true" :checkable="false" @select="onUserSelect" :show-icon="true">
                        <a-icon slot="user" type="user" />
                    </a-tree>
                </div>
            </div>
            <template slot="footer">
                <a-button type="primary" html-type="submit" @click="distributionSave">确定</a-button>
                <a-button :style="{ marginLeft: '8px' }" @click="() => {this.userModal=false}">关闭</a-button>
            </template>
        </a-modal>

        <!-- <inventoryModal ref="invenRef" @setValue="setValue"></inventoryModal> -->

    </div>
</template>

<script>

import { inventoryModal } from "@/components/PopUpLayer";//各种搜索选择弹窗

import { getPhonetic } from "@/api/common/py";
import {
    PageList,
    Save as SaveCustomer,
    receive,
    release,
    dealSave,
    potentialSave,
    saveShare,
    distributionSave,
    disable,
    enable,
    collectAdd,
    collectOut,
    combineSave,
    exportData,
    importTemplate,
    getExcelFiled,
    getDistrivetorExcelFiled,
    distrivetorImport,
    importData,
    downloadFailCause
} from "@/api/crm/customer";




import { initValidator, checkAll } from "@/utils/validator/validator";
import { TreeDataOffice } from "@/api/office";
import { Controlwidth } from "@/utils/antTableComponents";
import { officeUserListToTree, searchInTreeData, areaPageListToTreeForId } from "@/utils/tree";
import { clearValue, clearKeys } from "@/utils/tool/object";
import getDate from "@/utils/tool/date";
import { treeList } from "@/api/area";

import dynamicList from "@/mixins/dynamicList";
import { downloadDemo, importSupplierData, exportSupplierData } from "@/api/erp/vendor";//导入导出

export default {
    mixins: [dynamicList],
    components: {
        inventoryModal
    },
    data () {
        const filedColumns = [
            {
                title: "Excel字段",
                dataIndex: "excelFiled",
                key: "excelFiled",
                align: "left",
                width: 100,
            },
            {
                title: "系统字段",
                dataIndex: "crmFiled",
                key: "crmFiled",
                align: "left",
                width: 100,
                scopedSlots: { customRender: "crmFiled" }
            }
        ];
        //表格 头部 可伸缩
        return {
            importEnd: false,
            searchType: 0,        //0:线索客户 1.潜在客户 2.成交客户  3.联系人 4.联系人记录  5.商机 
            source: "crm",
            crmType: 0,        //客户大类 0:线索客户   1.潜在客户 2.成交客户     

            FixedConditionKeys: ["crmName", "phonetic"],  //固定的搜索条件的Key
            excludeDefineFields: ["collarUserId", "officeName", "shareType"],     //排除的启用字段
            customRenderCode: ["crmName", "shareType"], //table 使用插槽的列
            selectedUserKeys: [], //用户选择key
            selectedUserName: "", //用户tree选择name
            selectedMergeKeys: [], //客户合并key
            userAllData: [], //所有用户tree数据
            expandedUserKeys: [], //用户tree展开keys
            userSearchData: [], //用户tree搜索数据
            treeAShow: false, //搜索用户tree
            treeBShow: true, //用户tree
            importVisible: false, //导入文件弹窗
            filedVisible: false, //字段匹配弹窗
            resultVisible: false, //导入结果弹窗
            excelFiled: [], //excel字段
            impotrResult: {}, //导入结果
            isSpinning: false, //导入加载框
            exportVisible: false, //导出弹窗
            exportValue: 0, //要导出选中的数量
            exportRadioValue: "1", //导出redio值
            crmCheckedDatas: [], //客户选中的数据
            userModal: false, //分配客户
            filedColumns,
            filedData: [],
            //行政区信息
            regions: [],
            //选择地区
            areaText: '',

            inventoryName: null,
            inventoryClassName: null,
            inventoryCode: null,
            inventoryId: null,
        };
    },
    mounted () {
        this.areaTree();
        TreeDataOffice({ isLoadUser: 2 }).then(response => {
            const { data } = response;
            const childrenNav = [];
            officeUserListToTree(data, childrenNav, "0");
            this.userAllData = childrenNav;
            this.userSearchData = childrenNav;
        });
    },
    updated () {
        Controlwidth("crm_tb", 50);
    },
    computed: {
        // 是否释放
        isAutomaticrelease: function () {
            const { permissions, crmType } = this;
            let isShow = false;
            if (
                (crmType == 0 && permissions.includes("crm:clue:automaticrelease"))
                || (crmType == 1 && permissions.includes("crm:potential:automaticrelease"))
                || (crmType == 2 && permissions.includes("crm:deals:automaticrelease"))
            ) {
                isShow = true;
            }
            return isShow;
        }
    },
    methods: {
        //地区选择事件
        onAreaChange (value, selectedOptions) {
            this.areaText = selectedOptions.map(o => o.areaName).join('/');
        },
        //加载 区域数据
        areaTree () {
            treeList()
                .then(response => {
                    if (response.code === 200) {
                        const { data } = response;
                        const childrenNav = [];
                        areaPageListToTreeForId(data, childrenNav, 0);
                        console.log("加载 区域数据:", childrenNav);
                        this.regions = childrenNav;
                    }
                })
                .catch(error => { });

        },
        //跳转到 客户详情
        goToDetail (item, tabkey) {
            const { permissions } = this;
            if (!this.customerId && permissions.includes("crm:clue:edit")) {
                this.$router.push(`/crm/customer/detail/${item.crmName}/${item.id}/${tabkey}`)
            }
        },
        //添加
        AddItem () {
            const { formPostData, formErrors } = this;
            clearKeys(formErrors);
            // formPostData.isRelease = true; 
            this.isFromShow = true;
            this.ModalVisible = true;
            console.log("AddItem_formErrors->", formErrors)
        },
        //编辑
        EdiItem () {
            if (this.selectedKeys.length != 1) {
                this.$message.warn("请选择一条客户数据");
                return false;
            }
            const item = this.crmCheckedDatas.find(f => f.id == this.selectedKeys[0]);
            this.goToDetail(item, 'crm');
        },
        onSerch () {
            const { postData } = this;
            postData.page.current = 1;
            this.PageList();
        },
        // 获取列表
        PageList () {
            const { postData, onOffDefineFields } = this;
            console.log("潜在客户——搜索条件：", onOffDefineFields);
            postData.dtos = onOffDefineFields;
            postData.page.size = this.pagination.pageSize;
            this.loading = true;
            PageList(postData).then(response => {
                this.loading = false;
                console.log("获取潜在客户列表", response);
                if (response.code === 200) {
                    const { data } = response;
                    const { records, total, current, size } = data;
                    //转换自定义数据数据
                    this.defineFieldsAddToData(records);

                    this.data = records;
                    console.log("转换后的数据：records", records);
                    Object.assign(this.pagination, {
                        total
                    });
                } else {
                    this.data = [];
                    this.$message.error(response.message);
                }
            })
                .catch(error => { });
        },
        //获取中文拼音首字母，并赋值拼音码
        getPhonetic () {
            const { formPostData } = this;
            if (!formPostData.phonetic) {
                getPhonetic({ keyword: formPostData.crmName }).then(response => {
                    if (response.code === 200) {
                        this.$set(this.formPostData, "phonetic", response.data || response.message);
                    }
                })
            }
        },
        //提交表单
        onSubmit () {
            const {
                crmType,
                formRules,
                formPostData,
                formErrors,
                onOffDefineFields
            } = this;
            //全部校验一次
            checkAll(this, formRules, formPostData, formErrors);
            if (Object.keys(formErrors).length > 0) {
                this.isFromShow = false;
                this.$nextTick(function () {
                    this.isFromShow = true;
                });
                return false;
            }
            //自定义字段 重组
            let defineFieldsSets = onOffDefineFields.filter(f => f.dataType == 2);
            let defineFields = {};
            //获取重组后的自定义集合
            this.getDefineFields(defineFields, formPostData, defineFieldsSets);
            Object.assign(formPostData, {
                crmType,
                defineFields: JSON.stringify(defineFields)
            });
            SaveCustomer(formPostData).then(response => {
                if (response.code === 200) {
                    this.$message.success("保存成功");
                    this.hideModal();
                    //刷新 列表
                    this.PageList();
                }
            })
        },
        //客户tabale check触发
        selection (keys, info) {
            this.selectedKeys = keys;
            console.log("rowKeys", info);
            this.crmCheckedDatas = info;
            this.exportValue = info.length;
        },
        //客户合并tabale check触发
        mergeSelection (keys, info) {
            this.selectedMergeKeys = keys;
            console.log(keys, info);
        },
        checkCrmKey () {
            if (this.selectedKeys.length < 1) {
                this.$message.warn("没有选择客户");
                return false;
            }
            return true;
        },
        //我的关注 切换
        tabMyCollect () {
            this.isCollected = !this.isCollected;
            Object.assign(this.postData, {
                isCollected: this.isCollected
            });
            this.PageList();
        },
        //关注客户
        collectAdd () {
            if (this.checkCrmKey()) {
                console.log("关注.....");
                collectAdd(this.selectedKeys).then(response => {
                    if (response.code == 200) {
                        this.$message.success("关注成功");
                        this.PageList();
                        this.selectedKeys = [];
                    }
                });
            }
        },
        //取消关注
        collectOut () {
            if (this.checkCrmKey()) {
                collectOut(this.selectedKeys).then(response => {
                    if (response.code == 200) {
                        this.$message.success("取消关注成功");
                        this.PageList();
                        this.selectedKeys = [];
                    }
                });
            }
        },
        //领用客户
        receive () {
            if (this.checkCrmKey()) {
                let _this = this;
                this.$confirm({
                    title: '提示',
                    content: '确定要领用吗？',
                    onOk () {
                        receive(_this.selectedKeys).then(response => {
                            if (response.code == 200) {
                                _this.$message.success(response.message);
                                _this.PageList();
                                _this.selectedKeys = [];
                            }
                        });
                    },
                    onCancel () {

                    },
                });
            }
        },
        //分配弹窗
        distribution () {
            if (this.checkCrmKey()) {
                this.userModal = true;
                this.treeAShow = false;
                this.treeBShow = true;
            }
        },
        //分配客户
        distributionSave () {
            if (this.checkCrmKey()) {
                if (this.selectedUserKeys[0].indexOf("user") != -1) {
                    distributionSave({
                        type: 1,
                        collarUserId: this.selectedUserKeys[0].split("_")[0],
                        collarUserName: this.selectedUserName,
                        ids: this.selectedKeys.toString()
                    }).then(response => {
                        if (response.code == 200) {
                            this.$message.success("分配成功");
                            this.PageList();
                            this.selectedKeys = [];
                            this.$refs["user-modal"].hide();
                        }
                    });
                } else {
                    this.$message.warn("请选择用户");
                }
            }
        },
        //删除
        disable () {
            if (this.checkCrmKey()) {
                let _this = this;
                this.$confirm({
                    title: '提示',
                    content: '确定要领用吗？',
                    onOk () {
                        disable({ ids: _this.selectedKeys.toString(), status: 2 }).then(
                            response => {
                                if (response.code == 200) {
                                    _this.$message.success("删除成功");
                                    _this.PageList();
                                    _this.selectedKeys = [];
                                }
                            }
                        );
                    },
                    onCancel () {

                    },
                });
            }
        },
        //导出客户数据
        exportCrmData () {
            // const { postData, onOffDefineFields } = this;
            // console.log("客户系统——搜索条件：", onOffDefineFields);
            // postData.dtos = onOffDefineFields;
            // if (this.exportRadioValue == 1) {
            //     if (this.exportValue == 0) {
            //         this.$nlyaToast.toast("请选择要导出的客户", {
            //             title: `错误`,
            //             variant: "danger",
            //             solid: true
            //         });
            //         return false;
            //     }
            //     postData.crmIds = this.selectedKeys;
            // } else {
            //     if (this.pagination.total == 0) {
            //         this.$nlyaToast.toast("没有客户数据不能导出", {
            //             title: `错误`,
            //             variant: "danger",
            //             solid: true
            //         });
            //         return false;
            //     }
            //     postData.crmIds = null;
            // }
            exportSupplierData().then(response => {
                let url = window.URL.createObjectURL(
                    new Blob([response], { type: "application/vnd.ms-excel" })
                );
                let link = document.createElement("a");
                link.style.display = "none";
                link.href = url;
                link.setAttribute("download", "供应商档案.xls");
                document.body.appendChild(link);
                link.click();
                this.resultVisible = false;
                this.exportVisible = false;
                this.selectedKeys = [];
            });
        },
        //导入(解析导入字段)
        importCrm () {
            //上传execl文件 匹配字段
            //this.$refs["merge-modal"].show();
            const formData = new FormData();
            let excelFile = document.getElementById("file").files[0];
            if (excelFile == null || excelFile.name == "") {
                this.$error({
                    title: "错误提示",
                    content: "文件不能为空"
                });
                return false;
            }

            var AllImgExt = ".xls|.xlsx|";
            var extName = excelFile.name
                .substring(excelFile.name.lastIndexOf("."))
                .toLowerCase();
            if (AllImgExt.indexOf(extName + "|") == -1) {
                this.$error({
                    title: "错误提示",
                    content: "文件格式错误，请上传xls、xxlsx类型文件"
                });
                return false;
            }

            let size = excelFile.size;
            size = size / (1024 * 1024);
            if (size >= 5) {
                this.$error({
                    title: "错误提示",
                    content: "文件过大,不能超过5M"
                });
                return;
            }

            formData.append("file", excelFile);
            formData.append("companyType", 'isSupplier');

            getDistrivetorExcelFiled(formData).then(response => {
                if (response.code == 200) {
                    this.importVisible = false;
                    let exlFiled = response.data.excelFiled;
                    if (exlFiled == null || exlFiled.length == 0) {
                        this.$error({
                            title: "错误提示",
                            content: "文件没有数据"
                        });
                        return;
                    }
                    this.filedVisible = true;
                    this.filedModelFooter = true;
                    this.excelFiled = exlFiled;
                    let crmFiled = response.data.crmFiled;
                    let cFiled = [];
                    let lFiled = [];
                    let tableFiledData = [];
                    // cFiled.push({ key: '', title: '  ' });
                    // for (let i = 0; i < crmFiled.length; i++) {
                    //     if (crmFiled[i].title.includes("联系人.")) {
                    //         lFiled.push(crmFiled[i]);
                    //     } else {
                    //         cFiled.push(crmFiled[i]);
                    //     }
                    // }

                    // console.log("获取表头", exlFiled);
                    for (let i = 0; i < exlFiled.length; i++) {
                        let item = crmFiled.find(f => f.title == exlFiled[i]);
                        // if (item && item.code == 'unitId') {
                        //     item.code = 'unitName';
                        // }
                        tableFiledData.push({
                            excelFiled: exlFiled[i],
                            crmFiled: crmFiled,
                            crmCode: item ? item.key : null
                        });
                        this.filedData = tableFiledData;
                    }
                    // }
                }
            });
        },
        //下载模版
        downloadTemplate () {
            importTemplate({ type: 2 }).then(response => {
                let url = window.URL.createObjectURL(
                    new Blob([response], { type: "application/vnd.ms-excel" })
                );
                let link = document.createElement("a");
                link.style.display = "none";
                link.href = url;
                link.setAttribute("download", "导入供应商档案模板.xls");
                document.body.appendChild(link);
                link.click();
            });
        },
        //导入数据
        importData () {
            this.isSpinning = true;
            this.filedModelFooter = false;
            let crmCodes = this.filedData.map(f => f.crmCode);
            console.log(crmCodes);
            const formData = new FormData();
            formData.append("file", document.getElementById("file").files[0]);
            let excelArray = this.filedData.map(f => f.excelFiled);;

            console.log(excelArray)
            formData.append("excelFiled", this.excelFiled);
            formData.append("dbFiled", crmCodes);
            distrivetorImport(formData).then(response => {
                if (response.code == 200) {
                    this.impotrResult = response.data;
                    this.resultVisible = true;
                    this.filedVisible = false;
                    this.isSpinning = false;
                    // this.PageList();
                    //刷新父组件数据
                    this.$emit('syncFun');
                } else {
                    this.filedVisible = false;
                    this.isSpinning = false;
                    this.$message.error("导入失败，请联系管理员");
                }
            });
        },
        //下载导入结果
        downloadImportResult () {
            console.log("下载导入结果", this.impotrResult);
            const formData = new FormData();
            formData.append("excelField", this.impotrResult.excelField);
            formData.append("failCause", this.impotrResult.failCause);
            formData.append("failData", JSON.stringify(this.impotrResult.failData));
            downloadFailCause(formData).then(response => {
                let url = window.URL.createObjectURL(
                    new Blob([response], { type: "application/vnd.ms-excel" })
                );
                let link = document.createElement("a");
                link.style.display = "none";
                link.href = url;
                link.setAttribute("download", "导入失败的数据和原因.xls");
                document.body.appendChild(link);
                link.click();
                this.resultVisible = false;
            });
        },
        //导入弹窗
        importFile () {
            this.importVisible = true;

            this.$nextTick(() => {
                let file = document.getElementById("file");
                if (file.outerHTML) {
                    file.outerHTML = file.outerHTML;
                } else {      //FF
                    file.value = "";
                }
            })

            this.inventoryName = null;
            this.inventoryClassName = null;
            this.inventoryCode = null;
            this.inventoryId = null;
        },
        //用户tree展开
        expanedChange (key, info) {
            this.expandedUserKeys = key;
        },
        //用户tree选择
        onUserSelect (key, info) {
            this.selectedUserKeys = key;
            this.selectedUserName = info.node.title;
            console.log(key, info);
        },
        //用户搜索
        onChange (e) {
            const value = e.target.value;
            console.log(value);
            if (value) {
                this.treeAShow = true;
                this.treeBShow = false;
                const keys = [];
                const treeData = searchInTreeData(
                    keys,
                    this.userAllData,
                    "title",
                    value
                );
                this.userSearchData = treeData;
                this.expandedUserKeys = keys;
            } else {
                this.treeAShow = false;
                this.treeBShow = true;
                //this.areaTreeData = treeAreaData;
                this.expandedUserKeys = [];
            }
        },
        selectModalShow () {
            //物料分类
            this.$nextTick(() => {
                this.$refs.invenRef.showModal('inventoryClassId');
                this.$refs.invenRef.getData();
            })
        },
        setValue (val) {
            //物料分类(如果选择物料分类，物料编码自动填入)
            console.log('valvalvalvalval:', val)
            if (val.code == 'inventoryClassId') {
                this.inventoryName = val.name;
                this.inventoryClassName = val.backdata.treeNames;
                this.inventoryCode = val.classCode;
                this.inventoryId = val.id;
            }
        },
    }
};
</script>
<style lang="less">
    .import-modal-mask {
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.4);

        .loading-content {
            position: absolute;
            left: 50%;
            top: 50%;
            margin-top: -28px;
            // margin-left: 100px;
            font-size: 14px;
            color: #fff;
            .ant-spin-dot {
                font-size: 60px;
            }
            .ant-spin-dot i {
                width: 30px;
                height: 30px;
                background: #fff;
            }
        }
    }
</style>
